<%@ page language="java"
	import="java.util.*,com.stone.sys.pojo.*"
	pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	String currentStatus = (String)request.getAttribute("currentStatus");
	TUser loginUser  = (TUser)session.getAttribute(IConstant.SESSION_TUSER);//系统当前登录用户
	String roles = (String) session.getAttribute(IConstant.SESSION_ROLES);
	boolean showButton = false;
	boolean showGDButton = false;
	if("00".equals(currentStatus) && roles.contains("tabl_ybzb"))
		showButton = true;
	else if(("01".equals(currentStatus) || "03".equals(currentStatus) ) 
		&& roles.contains("tabl_dzjs"))
		showButton = true;
	else if("02".equals(currentStatus) && roles.contains("tabl_ybfh"))
		showButton = true;
	else if("04".equals(currentStatus) && roles.contains("tabl_ybspxf"))
		showButton = true;
	else if("05".equals(currentStatus) && roles.contains("tabl_dzgd"))
		showGDButton = true;
%>
<html>
	<head>
		<title>继电保护及安全自动装置压板管理</title>
		<script type="text/javascript" src="<%=contextPath%>/js/validator.js"></script>
		<script type="text/javascript"
			src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript"
			src="<%=contextPath%>/js/jquery.autogrow.js"></script>
		<script type="text/javascript">
			$(document).ready (function() {
		
			$('textarea').autogrow();		
			});
			Ext.onReady(function(){
				var tb = new Ext.Toolbar({
			   		renderTo: document.all.tbar,
			    	items: [
				       {
				            text: '保存',
				            icon:"<%=contextPath%>/images/save.gif",
				             //hidden:<%=showButton || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
				             hidden:true,
			                 handler:function(){
				            	comt();
				            }
				        },'-',
						{
				            text: '提交',
				            icon:"<%=contextPath%>/" + "images/editlink.gif",
				            hidden:<%=(showButton || "1".equals(session.getAttribute("SESSION_ISADMIN")) && !"06".equals(currentStatus) ) ? false:true%>,
			                handler:function(){
				            	comt();
				            }
				        },'-',
				        {
				            text: '归档',
				            icon:"<%=contextPath%>/" + "images/editlink.gif",
				            hidden:<%=(showGDButton || "1".equals(session.getAttribute("SESSION_ISADMIN")) && "05".equals(currentStatus) ) ? false:true%>,
			                handler:function(){
				            	comt();
				            }
				        },'-',
				        {
				            text: '返回',
				            icon:"<%=contextPath%>/images/fanhui.png",
				            handler:function(){
				            	back();
				            }
				        }
			    	]
			    });
			});
			
		</script>
	</head>

	<body topmargin="0">
		<div id="tbar" style="position: absolute; display: block left :   0px; top: 0px; width: 100%; height: 35px; z-index: 1;"></div>
		<br>
		<div id="Layer" style="position: absolute; display: block left :   0px; top: 35px; width: 100%; height: 94%; z-index: 1000; overflow: auto;">
		<center>
				<!-- 信息提示 -->
				<div id="result">
					<font color="red">${info }</font>
				</div>
		</center>
		
		<%if("00".equals(currentStatus)){ %>
			<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!addTablYb.do">
				<s:hidden name="entity.id" />
				<s:hidden name="entity.status" value="01" />
				<s:hidden name="entity.fqr" />
				<s:hidden name="entity.startdate" />
				<table width="80%" border="0" id="infotab">
					<tr>
						<th width="20">编写人</th>
						<td><%=loginUser.getName() %></td>
						<th width="20">编写日期</th>
						<td><s:date name="entity.startdate" format="yyyy-MM-dd" /></td>
					</tr>
					<tr>
						<th width="20">设备编码</th>
						<td><input type="text" style="width:120" name="entity.sbid"/></td>
						<th width="20">设备名称</th>
						<td><input type="text" style="width:120" name="entity.sbname"/></td>
					</tr>
					<tr>
						<th>设备基本资料</th>
						<td colspan="3"><s:file id="myFile1" name="myFile1" size="80"></s:file></td>
					</tr>
				</table>
				
			</form>
		<%}else{ %>
			<%if("01".equals(currentStatus)){ %>
				<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!updateTablYb.do">
					<s:hidden name="entity.id" />
					<s:hidden name="entity.status" value="02" />
					<s:hidden name="entity.fqr" />
					<s:hidden name="entity.startdate" />
					<s:hidden name="entity.sbid" />
					<s:hidden name="entity.sbname" />
					<table width="80%" border="0" id="infotab">
						<tr>
							<th width="20">设备编码</th>
							<td><c:out value="${entity.sbid}"/></td>
							<th width="20">设备名称</th>
							<td><c:out value="${entity.sbname}"/></td>
						</tr>
						<tr>
							<th>定值计算</th>
							<td colspan="3"><s:file id="myFile1" name="myFile1" size="80"></s:file></td>
						</tr>
					</table>
					
				</form>
			<%}else if("02".equals(currentStatus)){ %>
				<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!updateTablYb.do">
					<s:hidden name="entity.id" />
					<s:hidden name="entity.status" value="04" />
					<s:hidden name="entity.fqr" />
					<s:hidden name="entity.startdate" />
					<s:hidden name="entity.sbid" />
					<s:hidden name="entity.sbname" />
					<s:hidden name="entity.dzjsr" />
					<s:hidden name="entity.dzjsrq" />
					<table width="80%" border="0" id="infotab">
						<tr>
							<th width="20">设备编码</th>
							<td><c:out value="${entity.sbid}"/></td>
							<th width="20">设备名称</th>
							<td><c:out value="${entity.sbname}"/></td>
						</tr>
						<tr>
							<th>复核</th>
							<td  colspan="3">
								<input type="radio" name="dzfh" value="Y" checked/>通过
								<input type="radio" name="dzfh" value="N"/>驳回
							</td>
						</tr>
						<tr>
							<th>复核意见</th>
							<td  colspan="3">
								<textarea name="entity.fhyj" style="width:99%; height: 60px; min-height: 20px;line-height:15pt" min="0" datatype="LimitB"  min="1"   max="2000"  datatype="Require"  msg="审批意见必须输入。且不超过一千个汉字。" ></textarea>
							</td>
						</tr>
					</table>
					
				</form>
			<%}else if("03".equals(currentStatus)){ %>
				<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!updateTablYb.do">
					<s:hidden name="entity.id" />
					<s:hidden name="entity.status" value="02" />
					<s:hidden name="entity.fqr" />
					<s:hidden name="entity.startdate" />
					<s:hidden name="entity.sbid" />
					<s:hidden name="entity.sbname" />
					<s:hidden name="entity.dzjsr" />
					<s:hidden name="entity.dzjsrq" />
					<table width="80%" border="0" id="infotab">
						<tr>
							<th width="20">设备编码</th>
							<td><c:out value="${entity.sbid}"/></td>
							<th width="20">设备名称</th>
							<td><c:out value="${entity.sbname}"/></td>
						</tr>
						<tr>
							<th>复核</th>
							<td  colspan="3">驳回</td>
						</tr>
						<tr>
							<th>复核意见</th>
								<td  colspan="3"><c:out value="${entity.fhyj}"/></td>
						</tr>
						<tr>
							<th>定值计算</th>
							<td colspan="3"><s:file id="myFile1" name="myFile1" size="80"></s:file></td>
						</tr>
					</table>
				</form>
			<%}else if("04".equals(currentStatus)){ %>
				<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!updateTablYb.do">
					<s:hidden name="entity.id" />
					<s:hidden name="entity.status" value="05" />
					<s:hidden name="entity.fqr" />
					<s:hidden name="entity.startdate" />
					<s:hidden name="entity.sbid" />
					<s:hidden name="entity.sbname" />
					<s:hidden name="entity.dzjsr" />
					<s:hidden name="entity.dzjsrq" />
					<s:hidden name="entity.fhr" />
					<s:hidden name="entity.fhrq" />
					<s:hidden name="entity.fhyj" />
					<table width="80%" border="0" id="infotab">
						<tr>
							<th width="20">设备编码</th>
							<td><c:out value="${entity.sbid}"/></td>
							<th width="20">设备名称</th>
							<td><c:out value="${entity.sbname}"/></td>
						</tr>
						<tr>
							<th>审批意见</th>
								<td  colspan="3">
									<textarea name="entity.spyj" style="width:99%; height: 60px; min-height: 20px;line-height:15pt" min="0" datatype="LimitB"  min="1"   max="2000"  datatype="Require"  msg="审批意见必须输入。且不超过一千个汉字。" ></textarea>
								</td>
						</tr>
						<tr>
							<th>调度送电措施</th>
							<td colspan="3"><s:file id="myFile1" name="myFile1" size="80"></s:file></td>
						</tr>
					</table>
				</form>
			<%}else if("05".equals(currentStatus)){ %>
				<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!updateTablYb.do">
					<s:hidden name="entity.id" />
					<s:hidden name="entity.status" value="06" />
					<s:hidden name="entity.fqr" />
					<s:hidden name="entity.startdate" />
					<s:hidden name="entity.sbid" />
					<s:hidden name="entity.sbname" />
					<s:hidden name="entity.dzjsr" />
					<s:hidden name="entity.dzjsrq" />
					<s:hidden name="entity.fhr" />
					<s:hidden name="entity.fhrq" />
					<s:hidden name="entity.spxfr" />
					<s:hidden name="entity.spxfrq" />
					<s:hidden name="entity.spyj" />
					<table width="80%" border="0" id="infotab">
						<tr>
							<th width="20">设备编码</th>
							<td><c:out value="${entity.sbid}"/></td>
							<th width="20">设备名称</th>
							<td><c:out value="${entity.sbname}"/></td>
						</tr>
					</table>
				</form>
			<%}else if("06".equals(currentStatus)){ %>
				<form id="frmM" class="ct" name="frmM" method="POST" enctype="multipart/form-data" action="<%=contextPath%>/tablYb!updateTablYb.do">
					<s:hidden name="entity.id" />
					<s:hidden name="entity.status" value="06" />
					<s:hidden name="entity.fqr" />
					<s:hidden name="entity.startdate" />
					<s:hidden name="entity.sbid" />
					<s:hidden name="entity.sbname" />
					<s:hidden name="entity.dzjsr" />
					<s:hidden name="entity.dzjsrq" />
					<s:hidden name="entity.fhr" />
					<s:hidden name="entity.fhrq" />
					<s:hidden name="entity.spxfr" />
					<s:hidden name="entity.spxfrq" />
					<s:hidden name="entity.spyj" />
					<table width="80%" border="0" id="infotab">
						<tr>
							<th width="20">设备编码</th>
							<td><c:out value="${entity.sbid}"/></td>
							<th width="20">设备名称</th>
							<td><c:out value="${entity.sbname}"/></td>
						</tr>
					</table>
				</form>
			<%} %>
		<br/><br/>
		<c:if test="${xsbFileList != null && fn:length(xsbFileList) > 0 }">
			<table width="80%" border="0" id="infotab">
			<th>附件列表</th>
			<c:forEach items="${xsbFileList}" var="xsbFile" varStatus="status">
				<tr>
					<td>
						<a href='<c:out value="${xsbFile.url}"/>' target="_blank"><c:out value="${xsbFile.filename}"/></a>
					</td>
				</tr>
			</c:forEach>
			</table>
		</c:if>
	<%} %>
	</div>
</body>
</html>
<script language="javascript">
	 // 保存
     function comt(){
        if(!Validator.Validate(frmM,1)){
			return false;
		}
     	document.frmM.submit();
     }
     
     // 返回
     function back() {
		//document.frmM.action = "<%=contextPath%>/tablYbList!getList.do";
		//document.frmM.submit();
		parent.window.location.href = "<%=contextPath%>/jsp/business/tabl/listTabBase.jsp?url=tablYbList!getList.do&countPerPage=20";
     }
</script>
